import httpUtil from "@/utils/httpUtil.js"


const initData = (option) => {

	if (option.a) {
		httpUtil.setA(option.a)
	}
	if (option.mobile) {
		setMobile(option.mobile)
	}
	if (option.param) {
		setParam(option.param)
	}
	if (option.push_id) {
		setParam(option.push_id)
		setPushId(option.push_id)
	}
	if (option.pushid) {
		setParam(option.pushid)
		setPushId(option.pushid)
	}
	if (option.token) {
		setParamToken(option.token)
	}

	if (option.clickid) {
		setParam(option.clickid)
	}
	if (option.clickId) {
		setParam(option.clickId)
	}
	if (option.tokenid) {
		setParam(option.tokenid)
	}
	if (option.tokenId) {
		setParam(option.tokenId)
	}
	if (option.adId) {
		setParam(option.adId)
	}
	// 捷迅参数
	if (option.qcjParamStr) {
		setParam(option.qcjParamStr)
	}
	// 捷停车
	if (option.jtcAdRequestId) {
		setParam(option.jtcAdRequestId)
	}
	let params ={
		a:httpUtil.getA()
	}
	// httpUtil.post('/api/Alipayad/status', params, resx => {
	

	
	// }, err => {
	
	// })
}

const setParam = (value) => {
	uni.setStorageSync('param', value)
}
const setMobile = (value) => {
	uni.setStorageSync('mobile', value)
}
const getMobile = () => {
	return uni.getStorageSync('mobile')
}
uni.getStorageSync('paramPushId')
const getParam = () => {
	console.log('getParam1', getPushId(), getParamToken())
	if (getPushId() && getParamToken()) {
		console.log('getParam2')
		return JSON.stringify({
			"push_id": getPushId(),
			"token": getParamToken()
		})
	}
	console.log('getParam3')
	return uni.getStorageSync('param')
}

const removeParam = () => {
	uni.removeStorageSync('param')
}

const setPushId = (value) => {
	uni.setStorageSync('paramPushId', value)
}

const getPushId = () => {
	return uni.getStorageSync('paramPushId')
}

const removePushId = () => {
	uni.removeStorageSync('paramPushId')
}

const setParamToken = (value) => {
	uni.setStorageSync('paramToken', value)
}

const getParamToken = () => {
	return uni.getStorageSync('paramToken')
}

const removeParamToken = () => {
	uni.removeStorageSync('paramToken')
}

const clearParam = () => {
	removeParam()
	removeParamToken()
	removePushId()
}

export default {
	initData,
	setParam,
	getParam,
	setParamToken,
	getParamToken,
	setPushId,
	getPushId,
	clearParam,
	setMobile,
	getMobile
}